package o;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import androidx.annotation.NonNull;
import o.beo.f;
import o.dex.a;
import o.dex.d;

public class fam implements dev, faj {
    private static fam ॱ;
    private boolean ˊ = false;
    private fae ˋ;
    private d ˎ;
    private dez ˏ;
    private boolean ᐝ = false;

    public static synchronized fam ॱ() {
        fam o_fam;
        synchronized (fam.class) {
            if (ॱ == null) {
                ॱ = new fam();
            }
            o_fam = ॱ;
        }
        return o_fam;
    }

    public fam() {
        fhz ˋ = fho.ˏ().ˋ("buoywindow");
        if (ˋ != null) {
            this.ˏ = (dez) ˋ.ॱ(dez.class);
            if (this.ˏ != null) {
                this.ˏ.ˎ((dev) this);
            }
        }
    }

    public void ॱ(@NonNull Context context, @NonNull dex o_dex) {
        ˏ(context, o_dex, null);
    }

    public void ˏ(@NonNull Context context, @NonNull dex o_dex, Bundle bundle) {
        if (context != null) {
            if (!ʻ(context)) {
                bfg.ˋ(false);
            } else if (this.ˏ != null) {
                String packageName;
                if (this.ˋ == null || this.ˋ.getGameInfo() == null) {
                    Logger.ˎ("BuoyWindowManager", "open window, mBuoyBridge=" + this.ˋ);
                } else {
                    packageName = this.ˋ.getGameInfo().getPackageName();
                    this.ˊ = bgd.ॱ().ˎ(context, packageName);
                    this.ᐝ = bgd.ॱ().ˋ(packageName);
                    this.ˏ.ˎ(this.ˊ);
                    this.ˏ.ˏ(this.ᐝ);
                    Logger.ˎ("BuoyWindowManager", "packageName:" + packageName + ", isUseNotchArea:" + this.ˊ);
                }
                int ˋ = this.ˏ.ˋ(context, o_dex, bundle);
                dez o_dez = this.ˏ;
                if (ˋ == 1) {
                    packageName = context.getResources().getString(f.ˊ);
                    bfg.ˋ(false);
                    this.ˋ.onFail(context.getResources().getString(f.ˋ, new Object[]{packageName}));
                    return;
                }
                this.ˎ = o_dex.ॱˊ();
            }
        }
    }

    public void ˋ(@NonNull Context context, @NonNull dex o_dex) {
        if (this.ˏ != null) {
            this.ˏ.ˏ(context, o_dex);
        }
    }

    public void ॱ(@NonNull Context context) {
        ॱ(context, true);
    }

    public void ॱ(@NonNull Context context, boolean z) {
        if (this.ˏ != null) {
            this.ˏ.ॱ(context);
        }
        if (z) {
            this.ˋ = null;
        }
        new bgj().ˊ(context);
    }

    public void ˊ(@NonNull Context context) {
        if (this.ˏ != null) {
            this.ˏ.ˎ(context);
        }
    }

    public void ˊ(@NonNull Context context, @NonNull dex o_dex) {
        if (this.ˏ != null) {
            this.ˏ.ˎ(context, o_dex);
        }
    }

    public void ˏ(@NonNull Context context, @NonNull dex o_dex) {
        if (this.ˏ != null) {
            this.ˏ.ˊ(context, o_dex);
            this.ˎ = o_dex.ॱˊ();
        }
    }

    public void ˎ(@NonNull Context context) {
        if (this.ˏ != null) {
            this.ˏ.ˏ(context);
        }
    }

    public void ˏ(@NonNull Context context) {
        if (this.ˏ != null) {
            this.ˏ.ˏ(context);
        }
        new bgj().ˊ(context);
        new bgt().ˋ(context);
    }

    public void ˊ(@NonNull Context context, long j) {
        if (this.ˏ != null) {
            this.ˏ.ॱ(context, j);
        }
        new bgj().ˊ(context);
        new bgt().ˋ(context);
    }

    public void ˋ(@NonNull Context context) {
        if (ʻ(context) && this.ˏ != null) {
            this.ˏ.ˋ(context);
        }
    }

    public boolean ॱ(a aVar) {
        if (this.ˏ != null) {
            return this.ˏ.ॱ(aVar);
        }
        return false;
    }

    public void ˊ(@NonNull Context context, Class<?> cls, Intent intent) {
        ˎ(context, cls, intent, true);
    }

    public void ˎ(@NonNull Context context, Class<?> cls, Intent intent, boolean z) {
        ˏ(context);
        if (!(intent == null || context == null)) {
            intent.putExtra("orientation", context.getResources().getConfiguration().orientation);
        }
        bga.ॱ().ॱ(null, cls, intent, null, z);
    }

    public void ॱ(@NonNull Context context, Class<?> cls, cjm o_cjm) {
        ॱ(context, (Class) cls, o_cjm, true);
    }

    public void ॱ(@NonNull Context context, Class<?> cls, fjb o_fjb, boolean z) {
        ˏ(context);
        bga.ॱ().ॱ(null, cls, o_fjb, null, z);
    }

    public void ॱ(@NonNull Context context, Class<?> cls, cjm o_cjm, boolean z) {
        ˏ(context);
        if (!(o_cjm == null || context == null)) {
            o_cjm.ॱ().putExtra("orientation", context.getResources().getConfiguration().orientation);
        }
        bga.ॱ().ॱ(null, cls, o_cjm, null, z);
    }

    public void ˋ(fae o_fae) {
        this.ˋ = o_fae;
    }

    public fae ˏ() {
        return this.ˋ;
    }

    public boolean ʻ() {
        if (this.ˏ != null) {
            return this.ˏ.ˋ();
        }
        return true;
    }

    public void ˎ() {
        if (this.ˋ != null) {
            this.ˋ.onShow();
        }
    }

    public void ˊ() {
        bgd.ॱ().ॱ(this.ˎ);
        if (this.ˋ != null) {
            this.ˋ.onClose();
        }
    }

    public void ˋ() {
        bgd.ॱ().ॱ(this.ˎ);
        if (this.ˋ != null) {
            this.ˋ.onHide();
        }
    }

    private boolean ʻ(@NonNull Context context) {
        if (bex.ˎ().ˏ().ˎ() || "CN".equalsIgnoreCase(eqp.ˋ())) {
            return true;
        }
        String string = context.getResources().getString(f.ˊ);
        ezx.ˎ().ˊ(context.getResources().getString(f.ʼ, new Object[]{string}));
        return false;
    }

    public boolean ॱॱ() {
        return this.ˊ;
    }

    public boolean ᐝ() {
        return this.ᐝ;
    }
}
